bitkeeper revision 1.1389.15.14 (428242a6WycHvjFblUGQbKtJd94NPg)
authorcl349@firebug.cl.cam.ac.uk <cl349@firebug.cl.cam.ac.uk>
Wed, 11 May 2005 17:36:38 +0000 (17:36 +0000)
committercl349@firebug.cl.cam.ac.uk <cl349@firebug.cl.cam.ac.uk>
Wed, 11 May 2005 17:36:38 +0000 (17:36 +0000)
Many files:
  Merge interface changes from previous 'Split out context fetching into
  separate DOM0 op' and 'xen,tools: pincpu use vcpu and cpumap_t' checkins.
xc_linux_save.c:
  Undo incorrect change from previous patch.
xc.h, xc_domain.c:
  Cleanup whitespace.
Signed-off-by: Christian Limpach <Christian.Limpach@cl.cam.ac.uk>
tools/libxc/xc.h
tools/libxc/xc_core.c
tools/libxc/xc_domain.c
tools/libxc/xc_linux_save.c
tools/python/xen/lowlevel/xc/xc.c
tools/python/xen/xend/XendDomainInfo.py
xen/common/dom0_ops.c
xen/include/public/dom0_ops.h

index b02426d5eaff7f981f629bf789ea5f9667c3b810..913581fe9d6fd8ce9b81c32404b3cf39da26a55f 100644 (file)
@@ -87,22 +87,22 @@ typedef struct xc_core_header {
 
 
 long xc_ptrace(enum __ptrace_request request, 
-              u32  domid,
-              long addr, 
-              long data);
+               u32  domid,
+               long addr, 
+               long data);
 
 long xc_ptrace_core(enum __ptrace_request request, 
-                   u32 domid, 
-                   long addr, 
-                   long data);
+                    u32 domid, 
+                    long addr, 
+                    long data);
 
 int xc_waitdomain(int domain, 
-                 int *status, 
-                 int options);
+                  int *status, 
+                  int options);
 
 int xc_waitdomain_core(int domain, 
-                      int *status, 
-                      int options);
+                       int *status, 
+                       int options);
 
 /*
  * DOMAIN MANAGEMENT FUNCTIONS
@@ -110,10 +110,6 @@ int xc_waitdomain_core(int domain,
 
 typedef struct {
     u32           domid;
-    unsigned int  flags;
-    unsigned int  processors;
-    unsigned int  vcpus;
-    u16           n_vcpus;     
     unsigned int  dying:1, crashed:1, shutdown:1, 
                   paused:1, blocked:1, running:1;
     unsigned int  shutdown_reason; /* only meaningful if shutdown==1 */
@@ -121,6 +117,7 @@ typedef struct {
     unsigned long shared_info_frame;
     u64           cpu_time;
     unsigned long max_memkb;
+    unsigned int  vcpus;
     s32           vcpu_to_cpu[MAX_VIRT_CPUS];
     cpumap_t      cpumap[MAX_VIRT_CPUS];
 } xc_dominfo_t;
@@ -134,8 +131,8 @@ int xc_domain_create(int xc_handle,
 
 
 int xc_domain_dumpcore(int xc_handle, 
-                      u32 domid,
-                      const char *corename);
+                       u32 domid,
+                       const char *corename);
 
 
 /**
@@ -202,9 +199,9 @@ int xc_domain_getinfo(int xc_handle,
  * @return 0 on success, -1 on failure
  */
 int xc_domain_get_vcpu_context(int xc_handle,
-                             u32 domid,
-                             u32 vcpu,
-                             vcpu_guest_context_t *ctxt);
+                               u32 domid,
+                               u32 vcpu,
+                               vcpu_guest_context_t *ctxt);
 
 int xc_domain_setcpuweight(int xc_handle,
                            u32 domid,
@@ -266,8 +263,8 @@ xc_plan9_build (int xc_handle,
                 u32 domid, 
                 const char *image_name,
                 const char *cmdline, 
-               unsigned int control_evtchn, 
-               unsigned long flags);
+                unsigned int control_evtchn, 
+                unsigned long flags);
 
 struct mem_map;
 int xc_vmx_build(int xc_handle,
@@ -444,7 +441,7 @@ void *xc_map_foreign_batch(int xc_handle, u32 dom, int prot,
                            unsigned long *arr, int num );
 
 int xc_get_pfn_list(int xc_handle, u32 domid, unsigned long *pfn_buf, 
-                   unsigned long max_pfns);
+                    unsigned long max_pfns);
 
 /*\
  *  GRANT TABLE FUNCTIONS
index 50fe1c26aae93cc11d62b13f31642b4d79be3281..2d6b7d0fa2b697c275e6bf5b20dc7cf20403ae06 100644 (file)
@@ -53,7 +53,10 @@ xc_domain_dumpcore(int xc_handle,
                goto error_out;
        }
        
-       for (i = 0; i < info.n_vcpus; i++) {
+       for (i = 0; i < sizeof(info.vcpu_to_cpu) / sizeof(info.vcpu_to_cpu[0]);
+            i++) {
+               if (info.vcpu_to_cpu[i] == -1)
+                       continue;
                if (xc_domain_get_vcpu_context(xc_handle, domid, i, &ctxt[i])) {
                        PERROR("Could not get all vcpu contexts for domain");
                        goto error_out;
@@ -63,7 +66,7 @@ xc_domain_dumpcore(int xc_handle,
        nr_pages = info.nr_pages;
 
        header.xch_magic = 0xF00FEBED; 
-       header.xch_nr_vcpus = info.n_vcpus;
+       header.xch_nr_vcpus = info.vcpus;
        header.xch_nr_pages = nr_pages;
        header.xch_ctxt_offset = sizeof(struct xc_core_header);
        header.xch_index_offset = sizeof(struct xc_core_header) +
@@ -72,7 +75,7 @@ xc_domain_dumpcore(int xc_handle,
            sizeof(vcpu_guest_context_t) + nr_pages * sizeof(unsigned long));
 
        write(dump_fd, &header, sizeof(struct xc_core_header));
-       write(dump_fd, &ctxt, sizeof(ctxt[0]) * info.n_vcpus);
+       write(dump_fd, &ctxt, sizeof(ctxt[0]) * info.vcpus);
 
        if ((page_array = malloc(nr_pages * sizeof(unsigned long))) == NULL) {
            printf("Could not allocate memory\n");
index ac82bcffd24af9e05b9b53c6363f1ee3d60f944e..ed0149c60d8950a7d67db41ca3b8a34dad66935e 100644 (file)
@@ -115,9 +115,6 @@ int xc_domain_getinfo(int xc_handle,
         if ( (rc = do_dom0_op(xc_handle, &op)) < 0 )
             break;
         info->domid      = (u16)op.u.getdomaininfo.domain;
-        info->processors = op.u.getdomaininfo.processors;
-       info->n_vcpus    = op.u.getdomaininfo.n_active_vcpus;
-       info->flags      = op.u.getdomaininfo.flags;
 
         info->dying    = !!(op.u.getdomaininfo.flags & DOMFLAGS_DYING);
         info->crashed  = !!(op.u.getdomaininfo.flags & DOMFLAGS_CRASHED);
@@ -140,8 +137,8 @@ int xc_domain_getinfo(int xc_handle,
         memcpy(&info->cpumap, &op.u.getdomaininfo.cpumap, 
                sizeof(info->cpumap));
 
-       next_domid = (u16)op.u.getdomaininfo.domain + 1;
-       info++;
+        next_domid = (u16)op.u.getdomaininfo.domain + 1;
+        info++;
     }
 
     if( !nr_doms ) return rc; 
@@ -150,9 +147,9 @@ int xc_domain_getinfo(int xc_handle,
 }
 
 int xc_domain_get_vcpu_context(int xc_handle,
-                              u32 domid,
-                              u32 vcpu,
-                              vcpu_guest_context_t *ctxt)
+                               u32 domid,
+                               u32 vcpu,
+                               vcpu_guest_context_t *ctxt)
 {
     int rc, errno_saved;
     dom0_op_t op;
index 43d12838ba6caea4d0520a1dfe1db7c62237695e..17000d668e84f83cd921e68d9be4831d20aaaef0 100644 (file)
@@ -345,20 +345,17 @@ retry:
         xcio_error(ioctxt, "Could not get vcpu context");
     }
 
-    if ( (info->flags & 
-          (DOMFLAGS_SHUTDOWN | (SHUTDOWN_suspend<<DOMFLAGS_SHUTDOWNSHIFT))) ==
-         (DOMFLAGS_SHUTDOWN | (SHUTDOWN_suspend<<DOMFLAGS_SHUTDOWNSHIFT)) )
+    if ( info->shutdown && info->shutdown_reason == SHUTDOWN_suspend )
     {
        return 0; // success
     }
 
-    if ( info->flags & DOMFLAGS_PAUSED )
+    if ( info->paused )
     {
        // try unpausing domain, wait, and retest       
        xc_domain_unpause( xc_handle, ioctxt->domain );
 
-       xcio_error(ioctxt, "Domain was paused. Wait and re-test. (%u)",
-                  info->flags);
+       xcio_error(ioctxt, "Domain was paused. Wait and re-test.");
        usleep(10000);  // 10ms
 
        goto retry;
@@ -367,12 +364,12 @@ retry:
 
     if( ++i < 100 )
     {
-       xcio_error(ioctxt, "Retry suspend domain (%u)", info->flags);
+       xcio_error(ioctxt, "Retry suspend domain.");
        usleep(10000);  // 10ms 
        goto retry;
     }
 
-    xcio_error(ioctxt, "Unable to suspend domain. (%u)", info->flags);
+    xcio_error(ioctxt, "Unable to suspend domain.");
 
     return -1;
 }
@@ -469,7 +466,7 @@ int xc_linux_save(int xc_handle, XcIOContext *ioctxt)
         goto out;
     }
     
-    nr_pfns = info.nr_pages
+    nr_pfns = info.max_memkb >> PAGE_SHIFT
 
     /* cheesy sanity check */
     if ( nr_pfns > 1024*1024 ){
@@ -556,8 +553,7 @@ int xc_linux_save(int xc_handle, XcIOContext *ioctxt)
 
        if ( suspend_and_state( xc_handle, ioctxt, &info, &ctxt) )
        {
-           xcio_error(ioctxt, "Domain appears not to have suspended: %u",
-                      info.flags);
+           xcio_error(ioctxt, "Domain appears not to have suspended");
            goto out;
        }
 
@@ -923,14 +919,12 @@ int xc_linux_save(int xc_handle, XcIOContext *ioctxt)
                if ( suspend_and_state( xc_handle, ioctxt, &info, &ctxt) )
                {
                    xcio_error(ioctxt, 
-                               "Domain appears not to have suspended: %u",
-                              info.flags);
+                               "Domain appears not to have suspended");
                    goto out;
                }
 
                xcio_info(ioctxt,
-                          "SUSPEND flags %08u shinfo %08lx eip %08u "
-                          "esi %08u\n",info.flags,
+                          "SUSPEND shinfo %08lx eip %08u esi %08u\n",
                           info.shared_info_frame,
                           ctxt.user_regs.eip, ctxt.user_regs.esi );
             } 
index 1a0470aaae4cc9c6c62844ce50b90d85d1276309..a7b4aba7c6e8c88ae3e895cc0cb1bc7b24a48521 100644 (file)
@@ -205,10 +205,9 @@ static PyObject *pyxc_domain_getinfo(PyObject *self,
                             Py_BuildValue("i", info[i].cpumap[j]));
         }
                  
-        info_dict = Py_BuildValue("{s:i,s:i,s:i,s:i,s:i,s:i,s:i,s:i,s:i"
+        info_dict = Py_BuildValue("{s:i,s:i,s:i,s:i,s:i,s:i,s:i,s:i"
                                   ",s:l,s:L,s:l,s:i}",
                                   "dom",       info[i].domid,
-                                  "cpu",       info[i].cpu,
                                   "vcpus",     info[i].vcpus,
                                   "dying",     info[i].dying,
                                   "crashed",   info[i].crashed,
index a040d31545643a4bb016f7d0b59a0dd08245e7c2..2af99694ab7aa121f92f7c63b024fe06bf089ff8 100644 (file)
@@ -370,7 +370,7 @@ class XendDomainInfo:
             if self.info['shutdown']:
                 reason = shutdown_reason(self.info['shutdown_reason'])
                 sxpr.append(['shutdown_reason', reason])
-            sxpr.append(['cpu', self.info['cpu']])
+            sxpr.append(['cpu', self.info['vcpu_to_cpu'][0]])
             sxpr.append(['cpu_time', self.info['cpu_time']/1e9])    
             sxpr.append(['vcpus', self.info['vcpus']])
             sxpr.append(['cpumap', self.info['cpumap']])
index e4e3fe74ea6e6797ebf064de147395a9d75efc90..b4fe12ecb95e7d87f83646129e724c6b4646572f 100644 (file)
@@ -303,13 +303,8 @@ long do_dom0_op(dom0_op_t *u_dom0_op)
         struct exec_domain        *ed;
         u64 cpu_time = 0;
         int vcpu_count = 0;
-        u32 processors = 0;
         int flags = DOMFLAGS_PAUSED | DOMFLAGS_BLOCKED;
 
-#if MAX_VIRT_CPUS > 32
-#error "update processors field in GETDOMAININFO"
-#endif
-
         read_lock(&domlist_lock);
 
         for_each_domain ( d )
@@ -333,46 +328,37 @@ long do_dom0_op(dom0_op_t *u_dom0_op)
                sizeof(op->u.getdomaininfo.vcpu_to_cpu));
         memset(&op->u.getdomaininfo.cpumap, 0,
                sizeof(op->u.getdomaininfo.cpumap));
-        for_each_exec_domain ( d, ed ) {
-            op->u.getdomaininfo.vcpu_to_cpu[ed->id] = ed->processor;
-            op->u.getdomaininfo.cpumap[ed->id]      = ed->cpumap;
-        }
 
         /* 
          * - domain is marked as paused or blocked only if all its vcpus 
          *   are paused or blocked 
          * - domain is marked as running if any of its vcpus is running
          */
-        
-        for_each_exec_domain(d, ed)  
-        { 
-            if (!((flags & DOMFLAGS_PAUSED) && test_bit(EDF_CTRLPAUSE, &ed->flags)))
-                flags &=  ~DOMFLAGS_PAUSED;
-            if (!((flags & DOMFLAGS_BLOCKED) && test_bit(EDF_BLOCKED, &ed->flags)))
-                flags &=  ~DOMFLAGS_BLOCKED;                
-            flags |= (test_bit(EDF_RUNNING,   &ed->flags) ? DOMFLAGS_RUNNING  : 0);
-
-            set_bit(ed->processor, &processors);
+        for_each_exec_domain ( d, ed ) {
+            op->u.getdomaininfo.vcpu_to_cpu[ed->id] = ed->processor;
+            op->u.getdomaininfo.cpumap[ed->id]      = ed->cpumap;
+            if (!test_bit(EDF_CTRLPAUSE, &ed->flags))
+                flags &= ~DOMFLAGS_PAUSED;
+            if (!test_bit(EDF_BLOCKED, &ed->flags))
+                flags &= ~DOMFLAGS_BLOCKED;
+            if (test_bit(EDF_RUNNING, &ed->flags))
+                flags |= DOMFLAGS_RUNNING;
             if ( ed->cpu_time > cpu_time )
                 cpu_time += ed->cpu_time;
             vcpu_count++;
         }
-        op->u.getdomaininfo.n_active_vcpus = vcpu_count;
+
         op->u.getdomaininfo.cpu_time = cpu_time;
+        op->u.getdomaininfo.n_vcpu = vcpu_count;
 
-        op->u.getdomaininfo.flags =
+        op->u.getdomaininfo.flags = flags |
             (test_bit( DF_DYING,      &d->flags)  ? DOMFLAGS_DYING    : 0) |
             (test_bit( DF_CRASHED,    &d->flags)  ? DOMFLAGS_CRASHED  : 0) |
             (test_bit( DF_SHUTDOWN,   &d->flags)  ? DOMFLAGS_SHUTDOWN : 0) |
-            flags;
-
-        op->u.getdomaininfo.flags |= 
             d->shutdown_code << DOMFLAGS_SHUTDOWNSHIFT;
 
-        op->u.getdomaininfo.processors  = processors;
         op->u.getdomaininfo.tot_pages   = d->tot_pages;
         op->u.getdomaininfo.max_pages   = d->max_pages;
-        op->u.getdomaininfo.n_vcpu      = d->shared_info->n_vcpu;
         op->u.getdomaininfo.shared_info_frame = 
             __pa(d->shared_info) >> PAGE_SHIFT;
 
@@ -388,33 +374,29 @@ long do_dom0_op(dom0_op_t *u_dom0_op)
         struct vcpu_guest_context *c;
         struct domain             *d;
         struct exec_domain        *ed;
-        int active_index = 0; 
-        int exec_domain_index;
 
-        exec_domain_index = op->u.getvcpucontext.exec_domain;
         d = find_domain_by_id(op->u.getvcpucontext.domain);
-
         if ( d == NULL )
         {
             ret = -ESRCH;
             break;
         }
 
-        if ( (exec_domain_index >= MAX_VIRT_CPUS) )
+        if ( op->u.getvcpucontext.exec_domain >= MAX_VIRT_CPUS )
         {
             ret = -EINVAL;
+            put_domain(d);
             break;
         }
         
-        for_each_exec_domain(d, ed)
+        ed = d->exec_domain[op->u.getvcpucontext.exec_domain];
+        if ( ed == NULL )
         {
-            if ( exec_domain_index == active_index ) 
-            {
-                op->u.getvcpucontext.exec_domain = ed->id;
-                break;
-            }
-            active_index++;
+            ret = -ESRCH;
+            put_domain(d);
+            break;
         }
+
         op->u.getvcpucontext.cpu_time = ed->cpu_time;
 
         if ( op->u.getvcpucontext.ctxt != NULL )
index 59f0e6e0440486253e0527fefd739d97dc8a932e..734b7c56678c8f0b5f31342a60832c06e3be2c14 100644 (file)
@@ -70,7 +70,6 @@ typedef struct {
 typedef struct {
     /* IN variables. */
     domid_t  domain;                  /* NB. IN/OUT variable. */
-    u16      n_active_vcpus;          /* # of vcpus currently active */
     /* OUT variables. */
 #define DOMFLAGS_DYING     (1<<0) /* Domain is scheduled to die.             */
 #define DOMFLAGS_CRASHED   (1<<1) /* Crashed domain; frozen for postmortem.  */
@@ -83,7 +82,6 @@ typedef struct {
 #define DOMFLAGS_SHUTDOWNMASK 255 /* DOMFLAGS_SHUTDOWN guest-supplied code.  */
 #define DOMFLAGS_SHUTDOWNSHIFT 16
     u32      flags;
-    u32      processors;       
     memory_t tot_pages;
     memory_t max_pages;
     memory_t shared_info_frame;       /* MFN of shared_info struct */
@@ -348,12 +346,11 @@ typedef struct {
 #define DOM0_GETVCPUCONTEXT      37
 typedef struct {
     domid_t domain;                   /* domain to be affected */
-    u16     exec_domain;              /* NB. IN: nth active cpu / OUT: actual cpu # */
+    u16     exec_domain;              /* vcpu # */
     vcpu_guest_context_t *ctxt;       /* NB. IN/OUT variable. */
     u64     cpu_time;                 
 } dom0_getvcpucontext_t;
 
-
 typedef struct {
     u32 cmd;
     u32 interface_version; /* DOM0_INTERFACE_VERSION */